package day3.Sleep;

public class Test {
    public static void main(String[] args) {
        ISleep sleep = new SleepImpl();
        sleep.sleep();

        //匿名内部类可以简化写法
        ISleep iSleep = new ISleep() {//匿名内部类
            @Override
            public void sleep() {
                System.out.println("睡觉觉");
            }
        };
        iSleep.sleep();



        //第二种写法
        new ISleep() {//匿名内部类
            @Override
            public void sleep() {
                System.out.println("睡觉觉");
            }
        }.sleep();

    }
}
